package com.bigdata.spark.core.rdd.operator.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @author Gerry chan
 * @version 1.0
 */
object Spark01_RDD_Operator_Transform {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(sparkConf)
    // RDD 算子
    val rdd = sc.makeRDD(List(1, 2, 3, 4))
    // 转换函数
    def mapFunction(num:Int):Int = {
      num * 2
    }

    val mapRDD:RDD[Int] = rdd.map(mapFunction)
    mapRDD.collect().foreach(println)

    sc.stop()

  }

}
